//
// Created by f12160c on 2018/7/26.
//

#include <iostream>
#include <vector>
#include<gtest/gtest.h>

#include "leetcode/leetcode.hpp"

using namespace std;

namespace {
    TEST(test_solveSudoku, 1) {
        vector<vector<char>> input = {{'5','3','.','.','7','.','.','.','.'},
                                      {'6','.','.','1','9','5','.','.','.'},
                                      {'.','9','8','.','.','.','.','6','.'},
                                      {'8','.','.','.','6','.','.','.','3'},
                                      {'4','.','.','8','.','3','.','.','1'},
                                      {'7','.','.','.','2','.','.','.','6'},
                                      {'.','6','.','.','.','.','2','8','.'},
                                      {'.','.','.','4','1','9','.','.','5'},
                                      {'.','.','.','.','8','.','.','7','9'}};
        vector<vector<char>> expect = {{'5','3','4','6','7','8','9','1','2'},
                                       {'6','7','2','1','9','5','3','4','8'},
                                       {'1','9','8','3','4','2','5','6','7'},
                                       {'8','5','9','7','6','1','4','2','3'},
                                       {'4','2','6','8','5','3','7','9','1'},
                                       {'7','1','3','9','2','4','8','5','6'},
                                       {'9','6','1','5','3','7','2','8','4'},
                                       {'2','8','7','4','1','9','6','3','5'},
                                       {'3','4','5','2','8','6','1','7','9'}};
        Solution::solveSudoku(input);

        ASSERT_EQ(expect, input);
    }

    TEST(test_solveSudoku, 2) {
        vector<vector<char>> input = {{'.','.','9','7','4','8','.','.','.'},
                                      {'7','.','.','.','.','.','.','.','.'},
                                      {'.','2','.','1','.','9','.','.','.'},
                                      {'.','.','7','.','.','.','2','4','.'},
                                      {'.','6','4','.','1','.','5','9','.'},
                                      {'.','9','8','.','.','.','3','.','.'},
                                      {'.','.','.','8','.','3','.','2','.'},
                                      {'.','.','.','.','.','.','.','.','6'},
                                      {'.','.','.','2','7','5','9','.','.'}};
        vector<vector<char>> expect = {{'5','1','9','7','4','8','6','3','2'},
                                       {'7','8','3','6','5','2','4','1','9'},
                                       {'4','2','6','1','3','9','8','7','5'},
                                       {'3','5','7','9','8','6','2','4','1'},
                                       {'2','6','4','3','1','7','5','9','8'},
                                       {'1','9','8','5','2','4','3','6','7'},
                                       {'9','7','5','8','6','3','1','2','4'},
                                       {'8','3','2','4','9','1','7','5','6'},
                                       {'6','4','1','2','7','5','9','8','3'}};
        Solution::solveSudoku(input);

        ASSERT_EQ(expect, input);
    }

}